from typing import Tuple

import numpy as np
from numpy import ndarray

from alphalib.contrib.strategy import z1_conf_types, z1_strategy

stg_list = []

def weight_func() -> Tuple[list, ndarray]:
    #bh_list = [55, 89, 144,165,320]
    bh_list = [165]
    return bh_list, np.ones(len(bh_list))


for n, w in zip(*weight_func()):
    conf = z1_strategy.Z1StrategyConfig(
        strategy_name=f'BollCountPunish_bh{n}',
        hold_period=1,
        long_factors=[z1_conf_types.F1FactorConfig('BollCountPunish', True, n, 0, 1)],
        short_factors=[z1_conf_types.F1FactorConfig('BollCountPunish', True, n, 0, 1)],
        filter_before_params=[
            z1_conf_types.F1FilterParams('df1', '涨跌幅max_fl_24', 'value', 'lte', 0.2, False, False),
            z1_conf_types.F1FilterParams('df2', '涨跌幅max_fl_24', 'value', 'lte', 0.2, False, False),
            z1_conf_types.F1FilterParams('df1', 'QuoteVolumeSum_fl_24', 'rank', 'lte', 60, False, False),
            z1_conf_types.F1FilterParams('df2', 'QuoteVolumeSum_fl_24', 'rank', 'lte', 60, False, False),
        ],
        if_use_spot=False,
        long_weight=1,
        short_weight=1,
        long_coin_num=5,
        short_coin_num=.1,
        stg_weight=w,
    )
    stg_list.append(z1_strategy.Z1Strategy(conf))

strategy = z1_strategy.Z1MultiStrategy(stg_list)
